package de.sendorian.app.forumArchive.dundjinni;

import static de.sendorian.app.forumArchive.renamer.Renamers.appendUserShortname;
import static de.sendorian.app.forumArchive.renamer.Renamers.both;
import static de.sendorian.app.forumArchive.renamer.Renamers.capitalizeFirst;
import static de.sendorian.app.forumArchive.renamer.Renamers.removeForbiddenChars;
import static de.sendorian.app.forumArchive.renamer.Renamers.removeHash;

import java.util.regex.Pattern;


import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import de.sendorian.app.forumArchive.Config;
import de.sendorian.app.forumArchive.domain.Forum;
import de.sendorian.app.forumArchive.domain.Post;
import de.sendorian.app.forumArchive.domain.Topic;
import de.sendorian.app.forumArchive.finder.Finder;
import de.sendorian.app.forumArchive.renamer.FileRenamer;


@Component
public class DundjinniConfigStrategy extends Config {

    public DundjinniConfigStrategy() {
        config = this;
        baseUrl = "http://www.dundjinni.com/forums/";
        datePattern = Pattern.compile("(\\d{2}/\\d{2}/\\d{4}).*at.*(\\d{1,2}:\\d{2}.m)");
        baseUrl = "http://www.dundjinni.com/forums/";
    }


    @Resource(name = "dundjinniForumFinder")
    public void setForumFinder(Finder<String, Forum> forumFinder) {
        this.forumFinder = forumFinder;
    }


    @Resource(name = "dundjinniPostFinder")
    public void setPostFinder(Finder<Topic, Post> postFinder) {
        this.postFinder = postFinder;
    }


    @Resource(name = "dundjinniTopicFinder")
    public void setTopicFinder(Finder<Forum, Topic> topicFinder) {
        this.topicFinder = topicFinder;
    }


    @Override
    public FileRenamer getDefaultRenamer() {
        return both(removeHash()).and(capitalizeFirst()).and(appendUserShortname()).and(removeForbiddenChars());
    }
}
